<template>
    <j-modal :title="title" :width="width" :visible="visible" switchFullscreen @ok="handleOk" @cancel="handleCancel"
        cancelText="关闭">
        <a-form-model :model="model">
            <a-row>
                <a-col :span="24">
                    <a-form-model-item label="储值增加" :labelCol="labelCol" :wrapperCol="wrapperCol">
                        <a-input v-model="model.walletBalanceAdd" placeholder="请输入数量"></a-input>
                    </a-form-model-item>
                </a-col>
            </a-row>
            <a-row>
                <a-col :span="24">
                    <a-form-model-item label="储值减少" :labelCol="labelCol" :wrapperCol="wrapperCol">
                        <a-input v-model="model.walletBalanceSub" placeholder="请输入数量"></a-input>
                    </a-form-model-item>
                </a-col>
            </a-row>
            <!-- <a-row>
                <a-col :span="24">
                    <a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol">
                        <a-input v-model="model.note" placeholder="请输入备注"></a-input>
                    </a-form-model-item>
                </a-col>
            </a-row> -->
        </a-form-model>
    </j-modal>
</template>

<script>
import { getAction, postAction } from '@api/manage'
export default {
    data() {
        return {
            labelCol: {
                xs: { span: 24 },
                sm: { span: 5 },
            },
            wrapperCol: {
                xs: { span: 24 },
                sm: { span: 16 },
            },
            title: '手动储值',
            width: 800,
            visible: false,
            model: {},
        }
    },
    methods: {
        show({ nameTakingMeal, phoneTakingMeals, companyId }) {
            this.model.nameTakingMeal = nameTakingMeal;
            this.model.phoneTakingMeals = phoneTakingMeals;
            this.model.companyId = companyId;
            console.log('nameTakingMeal, phoneTakingMeals, comapnyId',nameTakingMeal, phoneTakingMeals, companyId);
            this.visible = true;
        },
        async handleOk() {
            let { walletBalanceAdd, walletBalanceSub } = this.model;
            if (!walletBalanceAdd && !walletBalanceSub) {
                this.$message.warning('储值增加或者储值减少至少填写一个');
                return;
            }
            let res = await postAction('/hc/hcUser/refreshSingleMealSupplement', this.model)
            console.log('结果res', res);
            if (res.success) {
                this.$message.success('设置成功');
                this.handleCancel();
                this.$emit('loadData');
            } else {
                this.$message.success(res.message);
            }
        },
        handleCancel() {
            this.model = {};
            this.visible = false
        }
    }
}
</script>